package com.bs.web.rest;

import com.bs.domain.ServerExecuteInfo;
import com.bs.domain.Svc10MinutesExecuteInfo;
import com.bs.domain.SvcExecuteInfo;
import com.bs.domain.SvcTop5ExecuteInfo;
import com.bs.service.ServerAnalysisService;
import com.bs.service.Svc10MinutesExecuteInfoService;
import com.bs.service.SvcAnalysisService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Api(value = "svcAnalysis")
@RestController
@RequestMapping("/api/dashboard")
public class SvcAnalysisResource {

    @Autowired
    ServerAnalysisService serverAnalysisService;

    @Autowired
    SvcAnalysisService svcAnalysisService;

    @Autowired
    Svc10MinutesExecuteInfoService svc10MinutesExecuteInfoService;


    @GetMapping("/serverexecuteinfo")
    public List<ServerExecuteInfo> queryServerExecuteInfo(@RequestParam("partition") String partition,
                                                          @RequestParam("startTime") String startTime,
                                                          @RequestParam("endTime") String endTime,
                                                          @RequestParam("svcName") String svcName){
        return serverAnalysisService.getServerList(partition,startTime,endTime,svcName);
    }

    @GetMapping("/svcexecuteinfo")
    public List<SvcExecuteInfo> querySvcExecuteInfo(@RequestParam("partition") String partition,
                                                    @RequestParam("pid") long pid,
                                                    @RequestParam("startTime") String startTime,
                                                    @RequestParam("endTime") String endTime){
        return svcAnalysisService.getSvcList(partition,pid,startTime,endTime);
    }


    @GetMapping("/svc10minutesexecuteinfo")
    public List<Svc10MinutesExecuteInfo> querySvc10MinutesExecuteInfo(@RequestParam("partition") String partition,
                                                                      @RequestParam("startTime") String startTime,
                                                                      @RequestParam("endTime")String endTime,
                                                                      @RequestParam("svcName") String svcName){
        return svc10MinutesExecuteInfoService.getExecuteInfo(partition,startTime,endTime,svcName);
    }


    @GetMapping("/svctop5executeinfo")
    public List<SvcTop5ExecuteInfo> querySvcTop5ExecuteInfo(@RequestParam("key") String key){
        return svc10MinutesExecuteInfoService.getSvcTop5ExecuteInfo(key);
    }


}
